derivative brian mclogan chain rule